<% if(!_.isEmpty(activity) && activity != null){ %> 
	<% if(activity.attributes.type !== 'add_permission'&& activity.attributes.type !== 'remove_permission') { %>
	<% var unread = ""; %>
	<% if(!_.isUndefined(authuser) && !_.isUndefined(authuser.user) && !_.isUndefined(activity.from_footer) && parseInt(activity.attributes.id) > parseInt(authuser.user.unread_activity_id)){ %>
		 <%if(activity.attributes.token !== authuser.access_token){%> 
		 <% var unread = "js-unread-activity"; %> 
		 <span class="label label-primary col-xs-12 sr-only">&nbsp;</span>   
		<%}%>    
	<% } %>                   
	<div class="media <%= unread %> modal-<% if((activity.attributes.type == 'add_comment' ||  activity.attributes.type == 'edit_comment')) {%>comments<%} else { %>activities<%}%> <% if(!_.isUndefined(authuser.user) &&  activity.attributes.user_id == authuser.user.id) {%>modal-logged-user-activities<%}%>">
	<% if(!_.isUndefined(activity.attributes.full_name) && !_.isEmpty(activity.attributes.full_name)) {%>
		<a  title="<%-activity.attributes.full_name %> (<%-activity.attributes.username %>)" class="js-tooltip pull-left" href="#/user/<%- activity.attributes.user_id %>">
			<% if(!_.isEmpty(activity.attributes.profile_picture_path)) {
				var profile_picture_path = activity.showImage('User', activity.attributes.user_id, 'small_thumb' );
			 %>      
				<img src="<%=profile_picture_path %>" alt="[Image: <%-activity.attributes.full_name %>]" title="<%-activity.attributes.full_name %> (<%-activity.attributes.username %>)" class="img-rounded img-responsive">
			<% } else {%> 
				<i class="avatar avatar-color-194 img-rounded"><%- activity.attributes.initials %></i>
			<% } %>
		</a>
	<% } else {%>	
		<% if(!activity.attributes.full_name || !activity.attributes.username){
			activity.attributes.full_name = i18next.t("[deleted account]");
			activity.attributes.username =  i18next.t("[deleted user]");
		}%>
		<i class="avatar avatar-color-194 img-rounded pull-left" title="<%-activity.attributes.full_name %>"></i>
	<% } %>
		<div class="media-body">    
			<%  activity.attributes.comment = filterXSS(activity.attributes.comment);
				activity.attributes.organization_name = (activity.attributes.organization_name !== null) ? activity.attributes.organization_name : i18next.t("[deleted]");
				activity.attributes.board_name = (activity.attributes.board_name !== null) ? activity.attributes.board_name : i18next.t("[deleted]");
				activity.attributes.card_name = (activity.attributes.card_name !== null) ? activity.attributes.card_name : i18next.t("[deleted]");
				var cardLink;
				if (activity.attributes.card_name !== '[deleted]') {
					cardLink = '<a href="#/board/' + activity.attributes.board_id + '/card/' + activity.attributes.card_id + '">' + _.escape(activity.attributes.card_name) + '</a>';
				} else {
					cardLink = '<a href="javascript:void(0);">' + _.escape(activity.attributes.card_name) + '</a>';
				}
				var organizationLink;
				if (activity.attributes.organization_name !== '[deleted]') {
					organizationLink = '<a href="#/organization/' + activity.attributes.organization_id + '">' + _.escape(activity.attributes.organization_name) + '</a>';
				} else {
					organizationLink = '<a href="javascript:void(0);">' + _.escape(activity.attributes.organization_name) + '</a>';
				}
				if(activity.attributes.type != 'add_comment') {
					if (activity.attributes.comment.indexOf('##DESCRIPTION##') != -1){
						if(activity.attributes.type !== 'add_card_desc') {
							if(!_.isEmpty(activity.attributes.difference) && !_.isUndefined(activity.attributes.difference) && !_.isUndefined(activity.attributes.difference['0'])){
								activity.attributes.comment = activity.attributes.comment.replace('##DESCRIPTION##', (activity.attributes.difference['0']));
							} else {
									activity.attributes.comment = activity.attributes.comment.replace('##DESCRIPTION##', (activity.attributes.card_description));
							}
						} else {
							activity.attributes.comment = activity.attributes.comment.replace(' - ##DESCRIPTION##', "");
						}
					}
					if(activity.attributes.comment.indexOf('##CARD_LINK##') != -1){
						activity.attributes.comment = activity.attributes.comment.replace('##CARD_LINK##', cardLink);
					}
					if(activity.attributes.comment.indexOf('##LABEL_NAME##') != -1){
						if (activity.attributes.label_name !== null) {
							activity.attributes.comment = activity.attributes.comment.replace('##LABEL_NAME##', (activity.attributes.label_name));
						} else {
							activity.attributes.comment = activity.attributes.comment.replace('##LABEL_NAME##', i18next.t("[deleted]"));
						}
					}
					if(activity.attributes.comment.indexOf('##CARD_NAME##') != -1){
						if (activity.attributes.card_name !== null) {
							activity.attributes.comment = activity.attributes.comment.replace('##CARD_NAME##', (activity.attributes.card_name));
						} else {
							activity.attributes.comment = activity.attributes.comment.replace('##CARD_NAME##', i18next.t("[deleted]"));
						}
					}
					if(activity.attributes.comment.indexOf('##ORGANIZATION_LINK##') != -1){
						activity.attributes.comment = activity.attributes.comment.replace('##ORGANIZATION_LINK##', organizationLink);
					}
					
					if(activity.attributes.comment.indexOf('##LIST_NAME##') != -1){
						if (activity.attributes.list_name !== null) {
							activity.attributes.comment = activity.attributes.comment.replace('##LIST_NAME##', (activity.attributes.list_name));
						} else {
							activity.attributes.comment = activity.attributes.comment.replace('##LIST_NAME##', i18next.t("[deleted]"));
						}
					}
					if(activity.attributes.comment.indexOf('##BOARD_NAME##') != -1){
						if (activity.attributes.board_name !== null) {
							activity.attributes.comment = activity.attributes.comment.replace('##BOARD_NAME##', (activity.attributes.board_name));
						} else {
							activity.attributes.comment = activity.attributes.comment.replace('##BOARD_NAME##', i18next.t("[deleted]"));
						}
					}
					if(activity.attributes.comment.indexOf('##USER_NAME##') != -1){
						activity.attributes.comment = activity.attributes.comment.replace('##USER_NAME##', '<span class="h5">'+_.escape(activity.attributes.full_name)+'</span>');					
					}
					if(activity.attributes.comment.indexOf('##CHECKLIST_ITEM_NAME##') != -1){
						if (activity.attributes.checklist_item_name !== null) {
							activity.attributes.comment = activity.attributes.comment.replace('##CHECKLIST_ITEM_NAME##', (activity.attributes.checklist_item_name));
						} else {
							activity.attributes.comment = activity.attributes.comment.replace('##CHECKLIST_ITEM_NAME##', i18next.t("[deleted]"));
						}
					}
					if(activity.attributes.comment.indexOf('##CHECKLIST_ITEM_PARENT_NAME##') != -1){
						if (activity.attributes.checklist_item_parent_name !== null) {
							activity.attributes.comment = activity.attributes.comment.replace('##CHECKLIST_ITEM_PARENT_NAME##', (activity.attributes.checklist_item_parent_name));
						} else {
							activity.attributes.comment = activity.attributes.comment.replace('##CHECKLIST_ITEM_PARENT_NAME##', i18next.t("[deleted]"));
						}
					}
					if(activity.attributes.comment.indexOf('##CHECKLIST_NAME##') != -1){
						activity.attributes.comment = activity.attributes.comment.replace('##CHECKLIST_NAME##', (activity.attributes.checklist_name));
					}
				} else if(activity.attributes.type != 'edit_comment'){
					if(!_.isUndefined(activity.from_footer)) {
						var comment = '<span>' + filterXSS(activity.attributes.full_name) + '</span> commented in card ' + cardLink;
						var matches = activity.attributes.comment.match(/@([^ ]*)/g);
						var _username = [];
						_.each(matches, function(match) {
							_username.push(match.substr(1));
						});
						if (!_.isEmpty(_username) && !_.isUndefined(authuser.user)){
							if (_.contains(_username, authuser.user.username)) {
								comment = filterXSS(activity.attributes.full_name) + ' has mentioned you in card ' + cardLink;
							} else if (_.contains(_username, 'card')) {
								comment = filterXSS(activity.attributes.full_name) + ' mentioned all the members in the card ' + cardLink;
							} else if (_.contains(_username, 'board')) {
								comment = filterXSS(activity.attributes.full_name) + ' mentioned all the board members in the card ' + cardLink;
							}
						} 
					}
				}
			%>             
			<div class="col-xs-12 btn-block">  
						<div class="activities-list js-activity-<%- activity.attributes.id %>">
						<% if(activity.attributes.type == 'add_comment') { 
							var originalComment;
							if (!_.isUndefined(activity.attributes.revisions) && !_.isEmpty(activity.attributes.revisions) && activity.attributes.revisions !== null) {
								originalComment = filterXSS(activity.attributes.revisions.old_value.comment);
							} else {
								originalComment = filterXSS(activity.attributes.comment);
							}
							if(!_.isUndefined(activity.from_footer)) { %>
								<span><%= comment %></span>
							<% } %>
							<% if (!_.isUndefined(type) && !_.isEmpty(type) && type !== null && type === 'board_user_activity') { %>
								<div class="thumbnail list-group-item-text no-whitespace">
									<%= makeLink(converter.makeHtml(originalComment), activity.attributes.board_id) %>
								</div>
							<% } else { %>
								<div class="panel no-mar">
									<div class="panel-body github-markdown no-whitespace">
										<% if (!_.isUndefined(type) && !_.isEmpty(type) && type !== null && type === 'modal_card') { %>
											<%= makeLink(converter.makeHtml(activity.attributes.comment), activity.attributes.board_id) %>
										<% } else { %>
											<%= makeLink(converter.makeHtml(originalComment), activity.attributes.board_id) %>
										<% } %>
										<% if(activity.attributes.difference != null && activity.attributes.difference != '' && !_.isUndefined(activity.attributes.difference['0']) && activity.attributes.difference['0'] != '' && _.contains(['edit_comment', 'edit_list', 'edit_organization', 'edit_board', 'update_card_checklist', 'update_profile', 'edit_card', 'delete_card_comment', 'edit_list_color'], activity.attributes.type)) { %>
											<div class="<%if(!_.isUndefined(activity.from_footer)) { %>thumbnail<% } %> list-group-item-text no-whitespace">
												<% _.each(activity.attributes.difference, function(difference) { %>
													<%= converter.makeHtml(difference) %>
												<% }); %>
											</div>
										<% } %>
									</div>
								</div>
							<% } %>
						<% } else { %>
							<%if(_.isUndefined(activity.from_footer)) { %>
								<div class="panel no-mar"><div class="panel-body github-markdown no-whitespace">
							<% } %>
							<% if((activity.attributes.type !== 'add_card_color' && activity.attributes.type !== 'delete_card_color' && activity.attributes.type !== 'edit_card_color')) { %>
								<%= makeLink(converter.makeHtml(activity.attributes.comment), activity.attributes.board_id) %>
							<% } else { %>
								<%= converter.makeHtml(activity.attributes.comment) %>
							<% } %>
								<% if(activity.attributes.type == 'add_card_desc'){ %>
									<div class="thumbnail list-group-item-text">
										<% if(activity.attributes.revisions != null && activity.attributes.revisions != "" && !_.isUndefined(activity.attributes.revisions.old_value) && !_.isUndefined(activity.attributes.revisions.new_value) && !_.isUndefined(activity.attributes.revisions.new_value.description) &&  activity.attributes.revisions.old_value.description == null) { %>
											<%= makeLink(converter.makeHtml(filterXSS(activity.attributes.revisions.new_value.description)), activity.attributes.board_id) %>
										<% } else if(activity.attributes.description){ %>
											<%= makeLink(converter.makeHtml(filterXSS(activity.attributes.description)), activity.attributes.board_id) %>
										<% } else if(activity.attributes.card_description){ %>	
											<%= makeLink(converter.makeHtml(filterXSS(activity.attributes.card_description)), activity.attributes.board_id) %>
										<% } %>				
									</div>
								<% } %>
								<% if(activity.attributes.difference != null && _.contains(['edit_comment', 'edit_list', 'edit_organization', 'edit_board', 'update_card_checklist', 'update_profile', 'edit_card', 'edit_list_color', 'edit_card_color', 'delete_card_color', 'edit_card_desc'], activity.attributes.type)) { %>
							<div class="<%if(!_.isUndefined(activity.from_footer) && !_.isEmpty(activity.attributes.difference) && !_.isEmpty(activity.attributes.difference['0'])) { %>thumbnail<% } %> list-group-item-text no-whitespace">
								<% if(!_.isEmpty(activity.attributes.difference) && !_.isEmpty(activity.attributes.difference['0'])) {
									_.each(activity.attributes.difference, function(difference) { %>
									<%= converter.makeHtml(difference) %>
								<% 	});
								} %>
							</div>
						<% } %>
							<%if(_.isUndefined(activity.from_footer)) { %>
								</div></div>
							<% } %>
						<% }%>
						
						</div>
						<small>
						&nbsp;&nbsp;
				<% if((activity.attributes.type == 'add_organization_attachment' || activity.attributes.type == 'change_visibility' || activity.attributes.type == 'add_organization_user' || activity.attributes.type == 'delete_organization_user') && (!_.isEmpty(activity.attributes.organization_name))) { %>
					<a href="<% if(activity.attributes.organization_name !== '[deleted]'){ %>#/organization/<%= activity.attributes.organization_id %><% }else{ %>javascript:void(0);<% } %>">&nbsp;<%- i18next.t("on") %>&nbsp;<%- activity.attributes.organization_name %></a>
				<% } else if(type == 'all' && activity.attributes.type != 'edit_organization' && activity.attributes.type != 'add_organization' && (!_.isEmpty(activity.attributes.board_name))) { %>
					<a class="pull-left" href="<% if(activity.attributes.board_name !== '[deleted]'){ %>#/board/<%= activity.attributes.board_id %><% }else{ %>javascript:void(0);<% } %>">&nbsp;<%- i18next.t("on") %>&nbsp;<%- activity.attributes.board_name %></a>
				<% } %>
				<% setInterval(function() {%>
					<% parse_date(activity.attributes.created, authuser,'js-timeago-'+activity.attributes.id); %>
				<% }, 10000); %>
				<span class="<% if(!_.isUndefined(type) && !_.isEmpty(type) && type === 'all' && activity.attributes.type !== 'add_organization' && activity.attributes.type !== 'edit_organization') { %>show<% } %> js-timeago-<%- activity.attributes.id %>"><%= parse_date(activity.attributes.created, authuser,'js-timeago-'+activity.attributes.id, true) %></span>
					<% if(!_.isUndefined(authuser.user) && activity.attributes.type == "add_comment" && type != "all" && (_.isUndefined(activity.from_footer))) { %>
						<div class="js-acticity-action-<%- activity.attributes.id %> pull-left navbar-btn col-md-10 col-xs-12">
							<ul class="list-inline">
							<% if(!_.isUndefined(authuser.user) && (authuser.user.role_id == 1 || ((!_.isEmpty(board.acl_links.where({slug: "comment_card",board_user_role_id: parseInt(activity.board_user_role_id)}))) || (!_.isEmpty(role_links.where({slug: "comment_card"})) && board.attributes.board_visibility == 2)))){ %>
								<li><a title="Reply" class="js-show-reply-activity-form js-reply-activity-link-<%- activity.attributes.id %>" href="javascript:void(0);" data-activity-id="<%- activity.attributes.id %>"><i class="icon-repeat"></i><%- i18next.t("Reply") %></a></li>
							<% } %>
							<% if(!_.isUndefined(authuser.user) && (authuser.user.role_id == 1 || !_.isEmpty(board.acl_links.where({slug: "delete_comment", board_user_role_id: parseInt(activity.board_user_role_id)})))){ %>
									<li class="dropdown pull-right">
										<a title="Delete" class="dropdown-toggle js-show-confirm-comment-delete text-danger" data-toggle="dropdown" href="#" data-activity-id="<%- activity.attributes.id %>" role="button"><i class="icon-remove"></i><%- i18next.t("Delete") %></a>
										<ul class="dropdown-menu arrow arrow-right">
											<li id="js-acticity-actions-response-<%- activity.attributes.id %>" class="js-dropdown-popup dropdown-popup"></li>
										</ul>
									</li>
								
							<% } %>
							<% if(!_.isUndefined(authuser.user) && (authuser.user.role_id == 1 || !_.isEmpty(board.acl_links.where({slug: "edit_comment", board_user_role_id: parseInt(activity.board_user_role_id)})))){ %>
								<li class="pull-right">
									<a title="Edit" class="js-show-edit-activity js-edit-activity-link-<%- activity.attributes.id %>" href="#" data-activity-id="<%- activity.attributes.id %>"  data-activity-temp-id="<%- activity.attributes.temp_id %>"><i class="icon-edit" data-activity-id="<%- activity.attributes.id %>"  data-activity-temp-id="<%- activity.attributes.temp_id %>"></i><%- i18next.t("Edit") %></a>
								</li>
							<% } %> 
							</ul>
						</div>
					<% } else if(activity.attributes.revisions != null && activity.attributes.revisions != "" && !_.isUndefined(authuser.user)){ %>
						<% if(!_.isEmpty(role_links.where({slug: "undo_activity"}))){ %>
							<% if(!_.isUndefined(activity.from_footer)) { %>
								<div class="js-acticity-action-<%- activity.attributes.id %>"><ul class="list-inline"><li><a title="Undo" class="js-undo2 col-xs-12 nav navbar-btn" href="#" data-activity-id="<%- activity.attributes.id %>"><i class="icon-undo"></i><%- i18next.t("Undo") %></a></li></ul></div>							
							<% } else { %>	
								<div class="js-acticity-action-<%- activity.attributes.id %>"><ul class="list-inline"><li><a title="Undo" class="js-undo col-xs-12 nav navbar-btn no-print" href="#" data-activity-id="<%- activity.attributes.id %>"><i class="icon-undo"></i><%- i18next.t("Undo") %></a></li></ul></div>
							<% }%>	
						<% } %>
					<% } %>
					<span class="pull-left col-xs-12 js-activity-reply-form-response-<%- activity.attributes.id %>"></span>
			</small>
			</div>
		</div>
	</div>
	
	
	
		<% if(_.isEmpty(unread)){ %> 
			<hr class="clearfix col-xs-12 btn-block"/>
		<%}%>
		<% if(!_.isEmpty(unread)){ %>
			<div class="well-sm clearfix"></div>
		<%}%>
		<%}%>
	<% }else{ %><div class="media-body alert alert-info"><%- i18next.t('No %s available.', { postProcess: 'sprintf', sprintf: [i18next.t('activities')] }) %></div><% } %>
	